<?php
class mod_admin extends CI_Model
{
	function mod_admin()
	{
		parent::__construct();
	}
	
	function login_admin($username, $password)
	{		
		$a = $this->db->get_where('admins',array('username'=>$username, 'password'=>$password, 'status'=>'1'));
		$_SESSION['admin_login'] = FALSE;	
		if ($a->num_rows()>0) 
		{				
			$row = $a->row_array();			
			$_SESSION['admin_id']			= $row['id'];
			$_SESSION['admin_login']		= TRUE;
			$_SESSION['username']			= $row['username'];	
			$_SESSION['show']				= 0;
			$_SESSION['error_loginadmin']	= '';					
			redirect(base_url().'admins/admin/index_admin');
		}
		else
		{
			$_SESSION['show']				= 1;
			$_SESSION['admin_id']			= '';
			$_SESSION['admin_login']		= FALSE;
			$_SESSION['username']			= '';
			$_SESSION['error_loginadmin']	= 'Username hoặc Password không hợp lệ!';			
			redirect(base_url().'adminx');
		}
	}
	
}